<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="carouselMapUpdateForm" name="carouselMapUpdateForm">
        <input type="hidden" name="carouselId" th:value="${carouselMap.carouselId}">
        <div class="form-group">
            <label class="col-sm-3 control-label">图片地址：</label>
            <div class="col-sm-8">
                <input name="imgUrl" class="form-control" type="text" required th:value="${carouselMap.imgUrl}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">当前窗口打开：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('system_carouselMap_target')}">
                    <input type="radio" th:id="${dict.dictCode}" name="target" th:value="${dict.dictValue}"
                           th:field="${carouselMap.target}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">标题：</label>
            <div class="col-sm-8">
                <input name="title" class="form-control" type="text" required th:value="${carouselMap.title}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">副标题：</label>
            <div class="col-sm-8">
                <textarea name="subTitle" class="form-control" th:text="${carouselMap.subTitle}"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">链接地址：</label>
            <div class="col-sm-8">
                <input name="url" class="form-control" type="text" required th:value="${carouselMap.url}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">显示：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('system_carouselMap_display')}">
                    <input type="radio" th:id="${dict.dictCode}" name="display" th:value="${dict.dictValue}"
                           th:field="${carouselMap.display}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="mail-body text-center tooltip-demo">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i
                    class="fa fa-check"></i>保 存
            </button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
                    class="fa fa-reply-all"></i>关 闭
            </button>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/carouselMap";

    $("#carouselMapUpdateForm").formValidate({
        rules: {
            imgUrl: {
                required: true,
            },
            title: {
                required: true,
                rangelength: [2, 45]
            },
            subTitle: {
                maxlength: 200
            },
            url: {
                required: true,
            },
        },
        messages: {
            "imgUrl": {
                required: "请输入图片地址",
            },
            "title": {
                required: "请输入标题",
                rangelength: "请输入长度为 {0} 至 {1} 之间的标题"
            },
            "subTitle": {
                maxlength: "最多输入{0}个字符"
            },
            "url": {
                required: "请输入链接地址",
            },
        },
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.saveTabPut(prefix + "/edit", $('#carouselMapUpdateForm').serialize());
        }
    }
</script>
</body>
</html>
